﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGiMaterialTextureManager : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGiMaterialTextureManager(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGiMaterialTextureManager_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGiMaterialTextureManager obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGiMaterialTextureManager()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGiMaterialTextureManager(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGiMaterialTextureManager cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_cast(OdRxObject.getCPtr(pObj));
			OdGiMaterialTextureManager result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMaterialTextureManager_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMaterialTextureManager_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGiMaterialTextureManager_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdGiMaterialTextureManager createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_createObject();
			OdGiMaterialTextureManager result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setManageType(OdGiMaterialTextureManager.ManageType type)
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_setManageType(this.swigCPtr, (int)type);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGiMaterialTextureManager.ManageType manageType()
		{
			OdGiMaterialTextureManager.ManageType result = (OdGiMaterialTextureManager.ManageType)GlobalsPINVOKE.OdGiMaterialTextureManager_manageType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setMaterialLoaderExt(OdGiMaterialTextureLoaderExt pExt)
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_setMaterialLoaderExt(this.swigCPtr, OdGiMaterialTextureLoaderExt.getCPtr(pExt));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGiMaterialTextureLoaderExt materialLoaderExt()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_materialLoaderExt(this.swigCPtr);
			OdGiMaterialTextureLoaderExt result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureLoaderExt)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureLoaderExt)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureLoaderExt)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData searchTexture(OdGiMaterialMap matMap)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_searchTexture__SWIG_0(this.swigCPtr, OdGiMaterialMap.getCPtr(matMap));
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData searchTexture(OdGiMaterialTexture pTexture)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_searchTexture__SWIG_1(this.swigCPtr, OdGiMaterialTexture.getCPtr(pTexture));
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData searchTexture(string fileName)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_searchTexture__SWIG_2(this.swigCPtr, fileName);
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData tryToLoad(OdGiMaterialTextureData.DevDataVariant pDeviceInfo, OdRxClass pTexDataImpl, OdGiContext giCtx, OdGiMaterialTextureEntry pEntry, OdGiMaterialMap matMap)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_tryToLoad__SWIG_0(this.swigCPtr, OdGiMaterialTextureData.DevDataVariant.getCPtr(pDeviceInfo), OdRxClass.getCPtr(pTexDataImpl), OdGiContext.getCPtr(giCtx), OdGiMaterialTextureEntry.getCPtr(pEntry), OdGiMaterialMap.getCPtr(matMap));
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData tryToLoad(OdGiMaterialTextureData.DevDataVariant pDeviceInfo, OdRxClass pTexDataImpl, OdGiContext giCtx, OdGiMaterialTextureEntry pEntry, OdGiMaterialTexture pTexture)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_tryToLoad__SWIG_1(this.swigCPtr, OdGiMaterialTextureData.DevDataVariant.getCPtr(pDeviceInfo), OdRxClass.getCPtr(pTexDataImpl), OdGiContext.getCPtr(giCtx), OdGiMaterialTextureEntry.getCPtr(pEntry), OdGiMaterialTexture.getCPtr(pTexture));
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData tryToLoad(OdGiMaterialTextureData.DevDataVariant pDeviceInfo, OdRxClass pTexDataImpl, OdGiContext giCtx, OdGiMaterialTextureEntry pEntry, string fileName)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_tryToLoad__SWIG_2(this.swigCPtr, OdGiMaterialTextureData.DevDataVariant.getCPtr(pDeviceInfo), OdRxClass.getCPtr(pTexDataImpl), OdGiContext.getCPtr(giCtx), OdGiMaterialTextureEntry.getCPtr(pEntry), fileName);
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void linkTexture(OdGiMaterialMap matMap, OdGiMaterialTextureData pData)
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_linkTexture__SWIG_0(this.swigCPtr, OdGiMaterialMap.getCPtr(matMap), OdGiMaterialTextureData.getCPtr(pData));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void linkTexture(OdGiMaterialTexture pTexture, OdGiMaterialTextureData pData)
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_linkTexture__SWIG_1(this.swigCPtr, OdGiMaterialTexture.getCPtr(pTexture), OdGiMaterialTextureData.getCPtr(pData));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void linkTexture(string fileName, OdGiMaterialTextureData pData)
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_linkTexture__SWIG_2(this.swigCPtr, fileName, OdGiMaterialTextureData.getCPtr(pData));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isAvailable(OdGiMaterialTextureData pData)
		{
			bool result = GlobalsPINVOKE.OdGiMaterialTextureManager_isAvailable(this.swigCPtr, OdGiMaterialTextureData.getCPtr(pData));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void unlinkTexture(OdGiMaterialTextureData pData)
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_unlinkTexture(this.swigCPtr, OdGiMaterialTextureData.getCPtr(pData));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void clear()
		{
			GlobalsPINVOKE.OdGiMaterialTextureManager_clear(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual uint numTextureEntries()
		{
			uint result = GlobalsPINVOKE.OdGiMaterialTextureManager_numTextureEntries(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTexture textureEntryKey(uint nIndex)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_textureEntryKey(this.swigCPtr, nIndex);
			OdGiMaterialTexture result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTexture)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGiMaterialTextureData textureEntryData(uint nIndex)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGiMaterialTextureManager_textureEntryData(this.swigCPtr, nIndex);
			OdGiMaterialTextureData result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiMaterialTextureData)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum ManageType
		{
			kFileTexturesOnly,
			kFileAndProceduralTextures,
			kDisable
		}
	}
}
